#include "../ecv/listutils.h"

int main (void)
{
  ecv_node * l11 = ecv_list_createnodefull(0,0,1);
  ecv_node * l12 = ecv_list_createnodefull(1,2,1);
  ecv_node * l13 = ecv_list_createnodefull(0,3,1);
  ecv_node * l14 = ecv_list_createnodefull(0,4,1);
  ecv_node * l21 = ecv_list_createnodefull(0,5,2);
  ecv_node * l22 = ecv_list_createnodefull(0,6,2);
  ecv_node * l23 = ecv_list_createnodefull(0,7,2);
  
  GHashTable * trees = g_hash_table_new(g_int_hash, g_int_equal);

  int id_1 = 1;

  g_hash_table_insert(trees, &id_1, l11);

  ecv_list_merge(l11,l12);
  ecv_list_merge(l12,l13);
  ecv_list_merge(l11,l14);

  int id_2 = 2;

  g_hash_table_insert(trees, &id_2, l21);

  ecv_list_merge(l21,l22);
  ecv_list_merge(l21,l23);
  ecv_list_merge(l12,l22);
  
  ecv_node * p = ecv_list_findhead(l22);

  while (p->child != NULL)
    {
      printf ("i = %i; j = %i\n", p->i,p->j);
      p = p->child;
    }

  GHashTableIter it;
  ecv_node * stptr;
  unsigned int * key;
  g_hash_table_iter_init(&it, trees);
  while (g_hash_table_iter_next(&it, (void**)&key, (void**)&stptr))
    {
      printf ("key = %i\n", *key);
    }

  return 0;
}
